package fun.boomcat.luckyhe.mirai.plugin.command.utils;

import fun.boomcat.luckyhe.mirai.plugin.bean.ReplyState;
import fun.boomcat.luckyhe.mirai.plugin.bean.ReplyType;

public class ReplyMapHandler {
    public static ReplyType getReplyType(String type) {
//        将String type映射到ReplyType类型
        type = type.toLowerCase();
        ReplyType rtype;
        switch (type) {
            case "cm":
            case "完全匹配":
                rtype = ReplyType.COMPLETE;
                break;
            case "fm":
            case "模糊匹配":
                rtype = ReplyType.FUZZY;
                break;
            case "re":
            case "正则匹配":
                rtype = ReplyType.REGEX;
                break;
            case "rr":
            case "正则替换":
                rtype = ReplyType.REGEX_REPLACE;
                break;
            default:
                throw new IllegalArgumentException("回复类型" + type + "错误");
        }
        return rtype;
    }

    public static ReplyState getReplyState(String state) {
//        将String state映射到ReplyState类型
        state = state.toLowerCase();
        ReplyState replyState;

        switch (state) {
            case "审核中":
                replyState = ReplyState.AUDITING;
                break;
            case "可用":
                replyState  = ReplyState.AVAILABLE;
                break;
            case "已删除":
                replyState = ReplyState.DELETED;
                break;
            default:
                throw new IllegalArgumentException("状态" + state + "错误");
        }

        return replyState;
    }
}
